//---------------------------------------
// 轮播图
class Banner {
    constructor(newBox) {
        this.box = newBox;
        //index是轮播图的索引，决定图片和小红点的位置
        this.index = 1;
        this.box.style.backgroundImage = "url(img/lunbo" + this.index + ".jpg)";
        this.eventBind();
    }

    //设置背景图
    setBgcImage() {
        this.box.style.backgroundImage = "url(img/lunbo" + this.index + ".jpg)";
    }

    prev() {
        this.index--;

        if (this.index == 0) {
            this.index = 2;
        }

        this.setBgcImage();
    }

    next() {
        this.index++;

        if (this.index == 3) {
            this.index = 1;
        }

        this.setBgcImage();
    }

    eventBind() {
        let oPrev = document.querySelector(".left");
        let oNext = document.querySelector(".right");
        let that = this;
        let time = setInterval(function() {
            that.next();
        }, 3000);
        oPrev.onclick = function() {
            that.prev();
        }

        oNext.onclick = function() {
            that.next();
        }
    }
}

let oBox = document.querySelector(".ban");

let b = new Banner(oBox);


//-----------------------------------------------
// 新品：男装女装
//图片效果
$("#new img").mouseover(function() {
    $(this).css({
        border: "2px solid black",
        padding: 5
    });
});
$("#new img").mouseout(function() {
    $(this).css({
        padding: 0,
        border: "none"
    });
});
//--------------------------------------------
// 男女装切换
$(".man").click(function() {
    $(this).css({
        borderBottom: "2px solid black"
    });
    $(".woman").css({
        borderBottom: "none"
    });
    $(".new-one").css({
        display: "block"
    });
    $(".new-two").css({
        display: "none"
    });
});
$(".woman").click(function() {
    $(this).css({
        borderBottom: "2px solid black"
    });
    $(".man").css({
        borderBottom: "none"
    });
    $(".new-one").css({
        display: "none"
    });
    $(".new-two").css({
        display: "block"
    });
});
// 商品详情页跳转
$("#new li").click(function(){
	location.href="details.html";
});